package com.eshop.we.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.eshop.we.leaseorder.entity.LeaseOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 出租订单 Mapper 接口
 * </p>
 *
 * @author anonymity
 * @since 2018-07-06
 */
public interface LeaseOrderMapper extends BaseMapper<LeaseOrder> {

    List<LeaseOrder> selectLeasePage(Page<LeaseOrder> page);

    List<LeaseOrder> selectIncomePage(Page<LeaseOrder> page);

    @Select("<script>" +
            " select *  " +
            " from lease_order " +
            " where 1=1 "+
            " <if test='orderNum!=null '>"+
            " and order_num like     CONCAT(CONCAT('%', #{orderNum}), '%') "+
            " </if>"+
            "<if test='providerName!=null '>"+
            " and provider_name like  CONCAT(CONCAT('%', #{providerName}), '%')"+
            " </if>"+
            "<if test='consumerName!=null '>"+
            " and consumer_name like  CONCAT(CONCAT('%', #{consumerName}), '%')"+
            " </if>"+
            "<if test='status!=null '>"+
            " and status =  #{status}"+
            " </if>"+
            " <if test='start!=null '>"+
            " and ctime &gt;=  #{start} "+
            " </if>"+
            " <if test='end!=null '>"+
            " and ctime &lt;=  #{end} "+
            " </if> "+
            " </script>")
    List<LeaseOrder> selectLeaseOrderPage(Page<LeaseOrder> page, @Param("orderNum") String orderNum, @Param("providerName") String providerName,@Param("consumerName") String consumerName, @Param("start")Long start, @Param("end")Long end, @Param("status")Integer status);
}
